import re


def get_sub_list(resource, pattern):
    r = re.finditer(pattern, resource)
    return list(r)


if __name__ == '__main__':
    with open('pi.txt', 'r') as f:
        pi = f.read()
    var1 = "19820705"
    r = get_sub_list(pi, var1)
    if len(r) >0:
        print(f"first match {r[0].group()} at {r[0].span()[0]} to {r[0].span()[1]}")

    var2 = "(19[6-9][0-9]|20[0-1][1-9]|202[0-1])"
    r = get_sub_list(pi, var2)
    if len(r) > 0:
        for m in r:
            print(f"match {m.group()} at {m.span()[0]} to {m.span()[1]}")
